package com.yxdj.service.api.factory;

import com.yxdj.common.core.domain.R;
import com.yxdj.service.api.RemoteMainCategoryService;
import com.yxdj.service.api.domain.MainCategory;
import org.springframework.cloud.openfeign.FallbackFactory;

import java.util.List;

/**
 * @author 韩总
 */
public class RemoteMainCategoryFallbackFactory implements FallbackFactory<RemoteMainCategoryService> {
    @Override
    public RemoteMainCategoryService create(Throwable cause) {
        return new RemoteMainCategoryService() {
            @Override
            public R<List<MainCategory>> getMainCategoryList(Integer limit, String source) {
                return R.fail("远程调用服务微服务获取前九个主分类失败："+ cause.getMessage());
            }

            @Override
            public R<List<MainCategory>> getAllCategory(String source) {
                return R.fail("远程调用服务微服务获取所有分类失败："+ cause.getMessage());
            }
        };
    }
}
